<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<style>
.detailTable input[type="text"]{
	width: 210px;
}
</style>
<div class="easyui-layout" style="width:100%;height:100%;" fit="true">
    
    <div data-options="region:'south',title:'',split:true" style="width: 100%;height: 280px">
		<form id="userInfoForm" method="post" >
			<input type="hidden" id="buyerId" name="buyerId" data-options="required:true">        
			<input type="hidden" id="userName" name="userName"><!-- 用户名：chsName -->
			<input type="hidden" id="email" name="email"><!-- 电子邮箱： -->
			<input type="hidden" id="qq" name="qq"><!-- QQ： -->
			<input type="hidden" id="address" name="address"><!-- 地址：address -->
			<input type="hidden" id="mobilePhone" name="mobilePhone"><!-- 手机号码： -->
			<input type="hidden" id="telePhone" name="telePhone"><!-- 座机： -->
			<input type="hidden" id="postCode" name="postCode"><!-- 邮编： -->
			<input type="hidden" id="notes" name="notes"><!-- 备注： -->
			<input type="hidden" id="linkMan" name="linkMan"><!-- 联系人： -->
			<input type="hidden" id="extendCode" name="extendCode"><!-- 企业编码： -->
			<table class="detailTable"> 
    	 	<tr>
                <th>登录名:</th> 
                <td><input class="easyui-validatebox " id="loginName" name="loginName" data-options="required:true"></td>
            </tr>
            <tr>
                <th>密码:</th>
                <td><input class="easyui-validatebox " type="password" id="loginPwd" name="loginPwd" data-options="required:true"></td>
            </tr>
            <tr>
                <th>再次输入密码:</th>
                <td><input class="easyui-validatebox " type="password" id="loginPwd1" name="loginPwd1" data-options="required:true" validType="same['loginPwd']"></td>
            </tr>
            <tr>
                <th>用户类型:</th>
                <td>
                    <input type="radio" id="userType" name="userType" value="2" checked="checked">药店
					<!-- <input type="radio" id="userType" name="userType" value="1" >厂家
					<input type="radio" id="userType" name="userType" value="3" >业务员   -->
               </td>
			<tr>
			   <td align="left"  > 
			   </td>
				<td align="left"  > 
					<input type="button" onclick="submitForm()" class="button" value="提交" >
				    <input type="button" onclick="pms.resetForm('userInfoForm')" class="button" value="重置" > 
				</td>
				
			</tr>
		</table>
		</form>
    </div>
    <div data-options="region:'center',split:true" style="width: 100%;height: 100%">
		<table id="userGrid"></table>
	</div>
</div>  
<script>
var tbl;
$(function(){
	initList();
})

function initList(){
	
	tbl = $('#userGrid').pDataGrid({
		 columns:[[
				  {field:'loginName',title:'登录名称',width:'200',sortable:true},
				  {field:'userName',title:'用户名称',width:'200',sortable:true},
				  {field:'isValid',title:'用户状态',width:'60',sortable:true,align:'center',
					  formatter:function(value,row){
						  var str = '';
							switch(value){
							case 0:
								str = '未审核';
								break;
							case 1:
								str = '已审核';
								break;
							case 2:
								str = '被锁定';
								break;
							}
							return str;
						}  
				  }
				  ]
			  ],
			url:'<c:url value="/buyer/showEmCBuyerDetail.do"/>',
		    pagination:false,
		    queryParams:{
		    	"buyerId":<%=request.getParameter("code")%>
		    },
		    completeCallback:function(data){
		    	var demo = data.data.emCBuyer;
				if(data.resultCode == "100"){
					alertError(data.result);
				}else{
					demoDetail(demo);
				} 
				
			}
	}); 
	
}
//返回数据load到from
function demoDetail(demo){
	$('#userInfoForm').form('load',{
		buyerId:demo.buyerId,
		userName:demo.chsName,
		address:demo.address,
		//mobilePhone:demo.mobile,
		telePhone:demo.phone,
		postCode:demo.zip,
		notes:demo.note,
		linkMan:demo.salesman,
		extendCode:demo.buyerCode
	});
}
function submitForm(){
	$('#userInfoForm').form('submit', {
	    url:"/admin/user/addProviderUser.do",  
	    onSubmit: function(param){
	    	if(!$("#userInfoForm").form('validate')){
	    		return false;
	    	}
	    	//alert(url);
	    	//时间对比
	    }, 
	    success:function(data){
		    var ret = eval("("+data+")");
	     	if(ret.code=='200'){
	     		alertShow("新增成功");
	     		buyersTable.refresh();
	     		$("#w_adduser").dialog('close');
		    }else{
		    	alertError(ret.result);
			}
	    }
	});
}


</script>
